import uniqueId from "@form-create/utils/lib/unique";
import { localeProps, makeRequiredRule } from "../../utils";

const label = "颜色选择器";
const name = "colorPicker";

export default {
  icon: "icon-color",
  label,
  name,
  rule({ t }) {
    return {
      type: "a-color-picker",
      field: uniqueId(),
      title: t("components.colorPicker.name"),
      info: "",
      $required: false,
      props: {},
    };
  },
  props(_, { t }) {
    return localeProps(t, name + ".props", [
      makeRequiredRule(),
      {
        type: "switch",
        field: "showText",
        title: "是否显示颜色值",
      },
      {
        type: "switch",
        field: "disabledAlpha",
        title: "是否支持透明度选择",
      },
      {
        type: "select",
        field: "format",
        title: "颜色的格式",
        options: [
          {
            label: "hsl",
            value: "hsl",
          },
          {
            label: "hsv",
            value: "hsv",
          },
          {
            label: "hex",
            value: "hex",
          },
          {
            label: "rgb",
            value: "rgb",
          },
        ],
      },
      {
        type: "switch",
        field: "disabled",
        title: "是否禁用",
      },
    ]);
  },
};
